﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using Business.Entity;
using Business.Dal;

namespace SahibindenUlkelerUtility
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            List<Ulke> UlkeList = new List<Ulke>();
            WebClient Client = new WebClient();
            Stream strm = Client.OpenRead(textBox1.Text);
            StreamReader sr = new StreamReader(strm);
            string line;
            line = sr.ReadLine();

            strm.Close();
            int LineNumber1 = 0;
            int LineNumber2 = 0;

            while (LineNumber1 < line.Length)
            {
                LineNumber1 = line.IndexOf("id", LineNumber1);
                LineNumber2 = line.IndexOf(":", LineNumber1 + 1);
                LineNumber1 = line.IndexOf(",", LineNumber2 + 1);
                string ID = line.Substring(LineNumber2, LineNumber1 - LineNumber2).Replace("'", "").Replace(":", "");
                LineNumber2 = line.IndexOf("text", LineNumber1);
                LineNumber1 = line.IndexOf(":", LineNumber2 + 1);
                LineNumber2 = line.IndexOf("}", LineNumber1 + 1);
                string Value = line.Substring(LineNumber1, LineNumber2 - LineNumber1).Replace("'", "").Replace(":", "");
                Ulke ulk = new Ulke(Convert.ToInt32( ID), Value);
                UlkeProvider prov = new UlkeProvider();
                prov.Insert(ulk);
            }
            
           

            


        }

        private void Ulke(int p, string Value)
        {
            throw new NotImplementedException();
        }
    }
}
